package de.IIIfeed.MoneyPlanner;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.AdapterView.OnItemSelectedListener;

public class Settings extends Activity {
    //private DatabaseHelper dbHelper;
	Spinner currency;
	ArrayAdapter<String> adapter;
    
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings);
        
        currency = (Spinner) this.findViewById(R.id.currency);
		String[] lv_arr = { "$", "€" };
		adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, lv_arr);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		currency.setAdapter(adapter);
		
		currency.setOnItemSelectedListener(new OnItemSelectedListener() {
			@Override
			public void onItemSelected(AdapterView<?> parent, View itemView,
					int itemPosition, long itemId) {
				SharedPreferences mPrefs = getSharedPreferences("MoneyPlannerPrefs", 0); 
				SharedPreferences.Editor editor = mPrefs.edit();
				editor.putString("currency", adapter.getItem(itemPosition));
				editor.commit();
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {
			}
		});
		

    }
    

}